package com.zxl.live.tools.alert;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.provider.Settings;

/**
 * 功能：
 * 作者： caijun
 * 时间： 2017/3/1  16 : 00
 */
public class MiuiGotoAlertSet implements AlertPermissionUtils.GotoAlertManager {
    private static final String SCHEME = "package";

    @Override
    public void gotoAlert(Context context) {
        try {
            ComponentName componentName = new ComponentName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
            Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
        //        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.setComponent(componentName);
            intent.putExtra("extra_pkgname", context.getPackageName());
            context.startActivity(intent);
        } catch (Exception e) {
            try {
                Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                intent.setData(Uri.fromParts(SCHEME, context.getPackageName(), null));
                context.startActivity(intent);
            } catch (Exception e1) {

            }
        }
    }
}
